<style>
.pro_box ul li{
	float:left;
	width:17%;
	margin-bottom:20px;
	}
.pro_box ul li a{
	width:56px;
	display:block;
	text-align:center;
	}

.laber_span{
	float:left;
	}
.l_div{
	overflow:hidden;
	padding:5px 0px 5px 0px;
	}	
.span_val{
	float:right;
	color: #999;
	}	
  
            	
</style>
<div class="box_right"  style="overflow:hidden;">
	<h1>
		活动管理
		
	</h1>
	<div class="pro_box">
			<ul style=" margin-left:50px; overflow:hidden;">
            	<li>
                <a href="javascript:void(0)" onclick="show_modal('first_order');">
                <img src="<?php echo base_url()?>themes/gasstation/images/shoudan.png" />
                首单立减</a>
                </li>
                
            	<li><a href="<?php echo site_url()?>gasstation/activity/index"><img src="<?php echo base_url()?>themes/gasstation/images/lipin.png" />活动赠品</a></li>
            	<li><a href="javascript:void(0)" onclick="show_modal('pay_coupon');"><img src="<?php echo base_url()?>themes/gasstation/images/quan.png" />消费返券</a></li>
                <li><a href="javascript:void(0)" onclick="show_modal('newuser_coupon');"><img src="<?php echo base_url()?>themes/gasstation/images/hongbao.png" />拉新红包</a></li>
                <li><a href="javascript:void(0)" onclick="show_modal('member_coupon');"><img src="<?php echo base_url()?>themes/gasstation/images/huiyuan.png" />会员派券</a></li>
            </ul>
			
            <div style="width:100%; margin-top:40px; clear:both;">
            
            
               <?php foreach($list as $v):?>
               <div style="width:45%; overflow:hidden; float:left; margin-bottom:20px; margin-right:40px; min-height:210px; ">
                   <div style="width:100%; overflow:hidden; float:left;">
                    <div class="l_div"><span style="font-size:23px; border-left:2px solid #ffc1b0; padding-left:5px;">
                    <?php echo $v['activity_type_name']?>
                    </span><span style="float:right; color:#63c45e; margin-top:5px;"><?php if($v['on']==1):?>进行中<?php else:?>未开始<?php endif;?></span></div>
                    <div class="l_div"><span class="laber_span">活动名称</span><span class="span_val"><?php echo $v['title']?></span></div>
                    <div class="l_div"><span class="laber_span">活动时间</span><span class="span_val" ><?php echo $v['start_time']?></span></div>
                    <div class="l_div"><span class="span_val" ><?php echo $v['end_time']?></span></div>
                    <div class="l_div"><span class="laber_span">面向对象</span><span class="span_val" ><?php echo $v['car_type']?></span></div>
                    <div class="l_div"><span class="laber_span">油品</span><span class="span_val" ><?php echo $v['gm']?></span></div>
                   </div>
                   <!--
                   <div style="float:left; width:50%; border:1px solid #CCC;">
                   
                   </div>
               	-->
                <div><a href="javascript:void(0)" style="float:right; color:#03F; padding-left:10px;" onclick="edit_activity(<?php echo $v['activity_type']?>,<?php echo $v['id']?>)">修改编辑</a><a href="javascript:void(0)" style="float:right; color:red; padding-right:10px;" onclick="stop_activity(<?php echo $v['id']?>)">停止活动</a><a href="javascript:void(0)" style="float:right; color:#03F; padding-right:10px;" onclick="top_activity(<?php echo $v['id']?>)"><?php if($v['top']==0):?>推荐到首页<?php else:?>取消推荐<?php endif;?></a></div>
               </div>
                <?php endforeach;?>
            	
                
                
                
                
                
                
                
                
                <?php foreach($off_line_activity as $v):?>
               <div style="width:45%; overflow:hidden; float:left; margin-bottom:20px; margin-right:40px; min-height:210px;">
                   <div style="width:100%; overflow:hidden; float:left;">
                    <div class="l_div"><span style="font-size:23px; border-left:2px solid #ffc1b0; padding-left:5px;">
                    活动赠品
                    </span><span style="float:right; color:#63c45e; margin-top:5px;"></span></div>
                    <div class="l_div"><span class="laber_span">活动名称</span><span class="span_val"><?php echo $v['activity_name']?></span></div>
                    <div class="l_div"><span class="laber_span">活动时间</span><span class="span_val" ><?php echo $v['start_time']?></span></div>
                    <div class="l_div"><span class="span_val" ><?php echo $v['end_time']?></span></div>
                    <div class="l_div"><span class="laber_span">审核状态</span><span class="span_val" ><?php if($v['check_status']==0):?>审核中<?php elseif($v['check_status']==1):?>审核通过<?php else:?>审核拒绝<?php endif;?></span></div>
                    
                   </div>
                   <!--
                   <div style="float:left; width:50%; border:1px solid #CCC;">
                   
                   </div>
               	-->
                <div><a href="<?php echo site_url()?>gasstation/activity/index" style="float:right; color:#03F; padding-left:10px;">修改编辑</a><a href="javascript:void(0)" style="float:right; color:#03F; padding-right:10px;" onclick="top_offline_activity(<?php echo $v['id']?>)"><?php if($v['top']==0):?>推荐到首页<?php else:?>取消推荐<?php endif;?></a></div>
               </div>
                <?php endforeach;?>
            
            
            </div>
	  
	   
	</div>
</div>



<div id="show_modal_div"  class="modal fade"  role="dialog" aria-hidden="true"></div>

<script type="text/javascript">




function show_modal(activity_name){
	if(activity_name=='first_order'){
			alert('该功能正在升级...');
			return false;
		}
	$.ajax({
	   type: "POST",
	   url:' <?php echo base_url()?>gasstation/activity/'+activity_name,
	   //data: "id="+id,
	   success: function(msg){
		 $('#show_modal_div').html(msg);
		 $('#show_modal_div').modal('show');
	   }
	});

}

function top_activity(id){
	
	
	$.ajax({
	   type: "POST",
	   url:' <?php echo base_url()?>gasstation/activity/top_activity/',
	   data: "id="+id,
	   success: function(msg){
		 window.location.reload();
	   }
	});
}

function top_offline_activity(id){
	
	$.ajax({
	   type: "POST",
	   url:' <?php echo base_url()?>gasstation/activity/offline_top_activity/',
	   data: "id="+id,
	   success: function(msg){
		 window.location.reload();
	   }
	});
	
}

function edit_activity(type,id){
	switch (type){
			case 1:
				var activity_name='first_order/'+id;
				break;
			case 3:
				var activity_name='pay_coupon/'+id;
				break;				
			case 4:
				var activity_name='newuser_coupon/'+id;
				break;
			case 5:
				var activity_name='member_coupon/'+id;
				break;						
		}
	$.ajax({
	   type: "POST",
	   url:' <?php echo base_url()?>gasstation/activity/'+activity_name,
	   data: "id="+id,
	   success: function(msg){
		 $('#show_modal_div').html(msg);
		 $('#show_modal_div').modal('show');
	   }
	});
	
	
	
	}
function stop_activity(a_id){
		
		if(confirm('是否终止活动')){
				
				$.ajax({
				   type: "POST",
				   url:' <?php echo base_url()?>gasstation/activity/stop_activity',
				   data: "id="+a_id,
				   success: function(msg){
					 alert('终止成功');
					 window.location.reload();
					 
				   }
				});
			
			}
	
	}

</script>